﻿using GameDesigner.Source;
using GameLibrary.Model.Core;
using Microsoft.VisualBasic.PowerPacks;

namespace GameDesigner.Displayers
{
    public abstract class ElementDisplayer 
    {
        private readonly ShapeContainer _ShapeContainer;
        private readonly GameDisplayer _GameDisplayer;
        private readonly SimpleShape _Shape;
        private readonly GameLocation _Location;

        public ElementDisplayer(GameDisplayer displayer, GameLocation point, 
            SimpleShape shape, ShapeContainer shapeContainer)
        {
            _GameDisplayer = displayer;
            _ShapeContainer = shapeContainer;
            _Location = point;
            _Shape = shape;
            _Shape.Location = point.ToPoint();
            _Shape.Size = new System.Drawing.Size(50, 50);
            _GameDisplayer.Displayers.Add(this);
            _ShapeContainer.Shapes.Add(shape);
        }

        public SimpleShape Shape
        {
            get { return _Shape; }
        }

        public GameLocation Location
        {
            get { return _Location; }
        }

        public GameDisplayer GameDisplayer
        {
            get { return _GameDisplayer; }
        }

        public static implicit operator Shape(ElementDisplayer o)
        {
            return o.Shape;
        }

        public void Clear()
        {
            _GameDisplayer.ClearShape(_Location);
        }

        public abstract void DisplayIcon();

    }
}
